﻿Imports Aricie.DNN.UI.Controls

Imports DotNetNuke.Entities.Modules

Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.UI.Skins
Imports DotNetNuke.UI.Skins.Controls
Imports Aricie.DNN.Security.Trial
Imports Aricie.DNN.Services.Url.FriendlyUrl.Security
Imports DotNetNuke.Entities.Modules.Actions

Namespace Aricie.DNN.Services.Url.FriendlyUrl

    Partial Public Class FriendlierUrlProviderConfig
        Inherits AriciePortalModuleBase
        Implements IActionable



        Public Const CONTROL_KEY As String = "EditConfig"

#Region "Private Members"
        Private Shared _ConfigFileName As String = ""

        Protected Friend ReadOnly Property ConfigurationKey As String
            Get
                Return "FUPConfig.Module." & PortalId & "." & ModuleId
            End Get
        End Property


        Private Property CurrentSettings As FriendlierUrlConfig
            Get
                Dim obj As Object = Session(ConfigurationKey)
                If (obj Is Nothing) Then
                    obj = Aricie.Services.ReflectionHelper.CloneObject(FriendlierUrlConfig.Instance)
                    Session(ConfigurationKey) = obj
                End If
                Return DirectCast(obj, FriendlierUrlConfig)
            End Get
            Set(value As FriendlierUrlConfig)
                Session(ConfigurationKey) = value
            End Set
        End Property



#End Region


#Region "Events Handlers"

        Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            Try
                Me.EnforceFreeVersion()
                If (Not IsPostBack) Then
                    CurrentSettings = Nothing
                End If
                Me.BindConfig()
            Catch ex As Exception
                ProcessModuleLoadException(Me, ex)
            End Try
           
        End Sub


       
#End Region


#Region "Private methods"

        Private Sub BindConfig()
            cfg.LocalResourceFile = Me.SharedResourceFile
            cfg.DataSource = CurrentSettings
            cfg.DataBind()
            cfg.EditMode = DotNetNuke.UI.WebControls.PropertyEditorMode.Edit
        End Sub


        Private Sub EnforceFreeVersion()
            Dim tc As TrialController = TrialController.Instance(New TrialProvider())
            Dim objTrialStatus As TrialStatusInfo = tc.LimitModule(Me, True)
            cfg.TrialStatus = objTrialStatus
        End Sub

#End Region


#Region "IActionable"


        Public ReadOnly Property ModuleActions() As DotNetNuke.Entities.Modules.Actions.ModuleActionCollection _
            Implements DotNetNuke.Entities.Modules.IActionable.ModuleActions
            Get
                Dim Actions As New DotNetNuke.Entities.Modules.Actions.ModuleActionCollection
                Actions.Add(GetNextActionID, _
                            Localization.GetString( _
                            FriendlierUrlProviderSettings.CONTROL_KEY, _
                            SharedResourceFile), _
                             DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent, _
                             "", "edit.gif", _
                             DotNetNuke.Common.Globals.NavigateURL(), _
                             False, _
                             DotNetNuke.Security.SecurityAccessLevel.Host, _
                             True, _
                             False)

                Actions.Add(GetNextActionID, _
                            Localization.GetString( _
                            FriendlierUrlProviderStoreEdit.CONTROL_KEY, _
                            SharedResourceFile), _
                             DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent, _
                             "", "edit.gif", _
                              Me.EditUrl(FriendlierUrlProviderStoreEdit.CONTROL_KEY), _
                             False, _
                             DotNetNuke.Security.SecurityAccessLevel.View, _
                             True, _
                             False)

                Return Actions
            End Get
        End Property


#End Region

       
    End Class

End Namespace

